package com.alifi.crm.dal.guess;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.alifi.crm.dal.IbatisCRUDDAO;
import com.alifi.crm.dal.object.TransmitLogDO;


@Repository("transmitLogDAO")
public class TransmitLogDAOImpl extends IbatisCRUDDAO<TransmitLogDO> implements TransmitLogDAO{

	@Override
	protected String getNamespace() {
		return "act_transmit_log";
	}
	
	public TransmitLogDO selectByEmployeeNumAndRecipient(String employeeNum,String recipient){
		Map<String,String> map = new HashMap<String,String>();
		map.put("employeeNum", employeeNum);
		map.put("recipient", recipient);
		return (TransmitLogDO)this.getSqlMapClientTemplate().queryForObject(this.genStmt("selectByEmployeeNumAndRecipient"),map);
	}

    @Override
    public int countTransmitTimesByEmployeeNum(String employeeNum) {
        return (Integer)this.getSqlMapClientTemplate().queryForObject(this.genStmt("countTransmitTimesByEmployeeNum"),employeeNum);
    }
    
    @Override
    public int countTransmitTimesByEmployeeNumByDate(String employeeNum, String gmtCreated) {
    	Map<String,String> map = new HashMap<String,String>();
    	map.put("employeeNum",employeeNum);
        map.put("startGmtCreated", gmtCreated + " 00:00:00");
        //map.put("endGmtCreated", gmtCreated + " 23:59:59");
        return (Integer)this.getSqlMapClientTemplate().queryForObject(this.genStmt("countTransmitTimesByEmployeeNumByDate"),map);
    }
    
    @Override
    public int countTransmitTimesByEmployeeNumByModifier(String employeeNum, String modifier) {
    	Map<String,String> map = new HashMap<String,String>();
    	map.put("employeeNum",employeeNum);
        map.put("modifier", modifier);
        //map.put("endGmtCreated", gmtCreated + " 23:59:59");
        return (Integer)this.getSqlMapClientTemplate().queryForObject(this.genStmt("countTransmitTimesByEmployeeNumByModifier"),map);
    }
}
